package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.dtos.SensitiveDto;
import com.heima.wemedia.service.SensitiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author 嘉德罗斯
 * @date 2021/11/29
 */
@RestController
@RequestMapping("/api/v1/sensitive")
public class SensitiveController {

    @Autowired
    private SensitiveService sensitiveService;

    @PostMapping("/list")
    public ResponseResult list(@RequestBody SensitiveDto dto){
        return sensitiveService.list(dto);
    }

    @PostMapping("/update")
    public ResponseResult update(@RequestBody SensitiveDto dto){
        return sensitiveService.update(dto);
    }

    @PostMapping("/save")
    public ResponseResult save(@RequestBody Map map){
        String sensitives = map.get("sensitives").toString();
        return sensitiveService.save(sensitives);
    }

    @DeleteMapping("del/{id}")
    public ResponseResult del(@PathVariable Integer id){
        return sensitiveService.del(id);
    }
}
